utilitify-core 1.0.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/LICENSE +21 -0
- package/README.md +338 -0
- package/dist/async.cjs +25 -0
- package/dist/async.cjs.map +1 -0
- package/dist/async.d.cts +104 -0
- package/dist/async.d.ts +104 -0
- package/dist/async.js +4 -0
- package/dist/async.js.map +1 -0
- package/dist/chunk-2ICNRTSN.cjs +346 -0
- package/dist/chunk-2ICNRTSN.cjs.map +1 -0
- package/dist/chunk-3DPF72DY.js +170 -0
- package/dist/chunk-3DPF72DY.js.map +1 -0
- package/dist/chunk-4CV4JOE5.js +24 -0
- package/dist/chunk-4CV4JOE5.js.map +1 -0
- package/dist/chunk-4SLYNSLH.cjs +783 -0
- package/dist/chunk-4SLYNSLH.cjs.map +1 -0
- package/dist/chunk-5WP7DWCG.js +1285 -0
- package/dist/chunk-5WP7DWCG.js.map +1 -0
- package/dist/chunk-BMQ6YPKV.js +876 -0
- package/dist/chunk-BMQ6YPKV.js.map +1 -0
- package/dist/chunk-BZCMWUKS.cjs +479 -0
- package/dist/chunk-BZCMWUKS.cjs.map +1 -0
- package/dist/chunk-C5R744DY.cjs +173 -0
- package/dist/chunk-C5R744DY.cjs.map +1 -0
- package/dist/chunk-C75J62CV.cjs +913 -0
- package/dist/chunk-C75J62CV.cjs.map +1 -0
- package/dist/chunk-CZLDE2OZ.cjs +28 -0
- package/dist/chunk-CZLDE2OZ.cjs.map +1 -0
- package/dist/chunk-DSMB6AF6.cjs +193 -0
- package/dist/chunk-DSMB6AF6.cjs.map +1 -0
- package/dist/chunk-ETWGPOPY.js +426 -0
- package/dist/chunk-ETWGPOPY.js.map +1 -0
- package/dist/chunk-FQBPVN63.cjs +403 -0
- package/dist/chunk-FQBPVN63.cjs.map +1 -0
- package/dist/chunk-G4GYQGTW.cjs +178 -0
- package/dist/chunk-G4GYQGTW.cjs.map +1 -0
- package/dist/chunk-GFDMZDMI.js +486 -0
- package/dist/chunk-GFDMZDMI.js.map +1 -0
- package/dist/chunk-HOTOYIPB.js +171 -0
- package/dist/chunk-HOTOYIPB.js.map +1 -0
- package/dist/chunk-HYADH4ZX.js +176 -0
- package/dist/chunk-HYADH4ZX.js.map +1 -0
- package/dist/chunk-JBN7C5WE.js +255 -0
- package/dist/chunk-JBN7C5WE.js.map +1 -0
- package/dist/chunk-JNCTPFTD.cjs +25 -0
- package/dist/chunk-JNCTPFTD.cjs.map +1 -0
- package/dist/chunk-N3BH3BV7.js +21 -0
- package/dist/chunk-N3BH3BV7.js.map +1 -0
- package/dist/chunk-NFPGAVRQ.js +749 -0
- package/dist/chunk-NFPGAVRQ.js.map +1 -0
- package/dist/chunk-OFFRGRBN.cjs +1332 -0
- package/dist/chunk-OFFRGRBN.cjs.map +1 -0
- package/dist/chunk-OZLKYIZL.cjs +490 -0
- package/dist/chunk-OZLKYIZL.cjs.map +1 -0
- package/dist/chunk-P3NUK46X.js +145 -0
- package/dist/chunk-P3NUK46X.js.map +1 -0
- package/dist/chunk-P7P2B7ZI.cjs +429 -0
- package/dist/chunk-P7P2B7ZI.cjs.map +1 -0
- package/dist/chunk-PB6SKSJN.cjs +150 -0
- package/dist/chunk-PB6SKSJN.cjs.map +1 -0
- package/dist/chunk-R3IXCJR7.js +378 -0
- package/dist/chunk-R3IXCJR7.js.map +1 -0
- package/dist/chunk-SD6P3WEJ.js +324 -0
- package/dist/chunk-SD6P3WEJ.js.map +1 -0
- package/dist/chunk-YSCHP26P.js +451 -0
- package/dist/chunk-YSCHP26P.js.map +1 -0
- package/dist/chunk-ZLMPRPCY.cjs +274 -0
- package/dist/chunk-ZLMPRPCY.cjs.map +1 -0
- package/dist/common-CBDYNJeh.d.cts +48 -0
- package/dist/common-CBDYNJeh.d.ts +48 -0
- package/dist/constants.cjs +42 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +60 -0
- package/dist/constants.d.ts +60 -0
- package/dist/constants.js +5 -0
- package/dist/constants.js.map +1 -0
- package/dist/country/index.cjs +154 -0
- package/dist/country/index.cjs.map +1 -0
- package/dist/country/index.d.cts +1 -0
- package/dist/country/index.d.ts +1 -0
- package/dist/country/index.js +5 -0
- package/dist/country/index.js.map +1 -0
- package/dist/date/index.cjs +117 -0
- package/dist/date/index.cjs.map +1 -0
- package/dist/date/index.d.cts +283 -0
- package/dist/date/index.d.ts +283 -0
- package/dist/date/index.js +4 -0
- package/dist/date/index.js.map +1 -0
- package/dist/environment/index.cjs +73 -0
- package/dist/environment/index.cjs.map +1 -0
- package/dist/environment/index.d.cts +127 -0
- package/dist/environment/index.d.ts +127 -0
- package/dist/environment/index.js +4 -0
- package/dist/environment/index.js.map +1 -0
- package/dist/form/index.cjs +81 -0
- package/dist/form/index.cjs.map +1 -0
- package/dist/form/index.d.cts +227 -0
- package/dist/form/index.d.ts +227 -0
- package/dist/form/index.js +4 -0
- package/dist/form/index.js.map +1 -0
- package/dist/i18n.cjs +37 -0
- package/dist/i18n.cjs.map +1 -0
- package/dist/i18n.d.cts +102 -0
- package/dist/i18n.d.ts +102 -0
- package/dist/i18n.js +4 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index-BXBmBHyL.d.ts +718 -0
- package/dist/index-BYsUCP3u.d.cts +718 -0
- package/dist/index-Cl26FrAZ.d.cts +362 -0
- package/dist/index-Cl26FrAZ.d.ts +362 -0
- package/dist/index.cjs +1265 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +205 -0
- package/dist/index.d.ts +205 -0
- package/dist/index.js +277 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.cjs +13 -0
- package/dist/schema.cjs.map +1 -0
- package/dist/schema.d.cts +84 -0
- package/dist/schema.d.ts +84 -0
- package/dist/schema.js +4 -0
- package/dist/schema.js.map +1 -0
- package/dist/security/index.cjs +94 -0
- package/dist/security/index.cjs.map +1 -0
- package/dist/security/index.d.cts +216 -0
- package/dist/security/index.d.ts +216 -0
- package/dist/security/index.js +5 -0
- package/dist/security/index.js.map +1 -0
- package/dist/string/index.cjs +153 -0
- package/dist/string/index.cjs.map +1 -0
- package/dist/string/index.d.cts +471 -0
- package/dist/string/index.d.ts +471 -0
- package/dist/string/index.js +4 -0
- package/dist/string/index.js.map +1 -0
- package/dist/transform/index.cjs +105 -0
- package/dist/transform/index.cjs.map +1 -0
- package/dist/transform/index.d.cts +271 -0
- package/dist/transform/index.d.ts +271 -0
- package/dist/transform/index.js +4 -0
- package/dist/transform/index.js.map +1 -0
- package/dist/validators/index.cjs +195 -0
- package/dist/validators/index.cjs.map +1 -0
- package/dist/validators/index.d.cts +2 -0
- package/dist/validators/index.d.ts +2 -0
- package/dist/validators/index.js +6 -0
- package/dist/validators/index.js.map +1 -0
- package/package.json +229 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Password strength result
|
|
3
|
+
*/
|
|
4
|
+
interface PasswordStrength {
|
|
5
|
+
/** Score from 0-4 (0 = very weak, 4 = very strong) */
|
|
6
|
+
score: 0 | 1 | 2 | 3 | 4;
|
|
7
|
+
/** Human-readable strength label */
|
|
8
|
+
label: 'very-weak' | 'weak' | 'fair' | 'strong' | 'very-strong';
|
|
9
|
+
/** Improvement suggestions */
|
|
10
|
+
suggestions: string[];
|
|
11
|
+
/** Requirements met */
|
|
12
|
+
requirements: {
|
|
13
|
+
minLength: boolean;
|
|
14
|
+
hasUppercase: boolean;
|
|
15
|
+
hasLowercase: boolean;
|
|
16
|
+
hasNumber: boolean;
|
|
17
|
+
hasSymbol: boolean;
|
|
18
|
+
noCommonPatterns: boolean;
|
|
19
|
+
};
|
|
20
|
+
/** Estimated crack time description */
|
|
21
|
+
crackTime: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Password strength options
|
|
25
|
+
*/
|
|
26
|
+
interface PasswordStrengthOptions {
|
|
27
|
+
/** Minimum length (default: 8) */
|
|
28
|
+
minLength?: number;
|
|
29
|
+
/** Require uppercase (default: true) */
|
|
30
|
+
requireUppercase?: boolean;
|
|
31
|
+
/** Require lowercase (default: true) */
|
|
32
|
+
requireLowercase?: boolean;
|
|
33
|
+
/** Require number (default: true) */
|
|
34
|
+
requireNumber?: boolean;
|
|
35
|
+
/** Require symbol (default: false) */
|
|
36
|
+
requireSymbol?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Check password strength
|
|
40
|
+
*
|
|
41
|
+
* @param password - Password to check
|
|
42
|
+
* @param options - Strength options
|
|
43
|
+
* @returns Password strength result
|
|
44
|
+
* @since 1.0.0
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const result = checkPasswordStrength('MyP@ssw0rd!');
|
|
49
|
+
* console.log(result.score); // 4
|
|
50
|
+
* console.log(result.label); // 'very-strong'
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
declare function checkPasswordStrength(password: string, options?: PasswordStrengthOptions): PasswordStrength;
|
|
54
|
+
/**
|
|
55
|
+
* Check if password meets requirements
|
|
56
|
+
*
|
|
57
|
+
* @param password - Password to check
|
|
58
|
+
* @param requirements - Requirements to check
|
|
59
|
+
* @returns true if all requirements met
|
|
60
|
+
*/
|
|
61
|
+
declare function meetsRequirements(password: string, requirements: Partial<PasswordStrengthOptions>): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Check if password is strong enough
|
|
64
|
+
*
|
|
65
|
+
* @param password - Password to check
|
|
66
|
+
* @param minScore - Minimum score (default: 3)
|
|
67
|
+
* @returns true if strong enough
|
|
68
|
+
*/
|
|
69
|
+
declare function isStrongPassword(password: string, minScore?: number): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Get password feedback message
|
|
72
|
+
*
|
|
73
|
+
* @param password - Password to check
|
|
74
|
+
* @returns Feedback message
|
|
75
|
+
*/
|
|
76
|
+
declare function getPasswordFeedback(password: string): string;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Hash a string using SHA-256
|
|
80
|
+
* Uses Web Crypto API for browser compatibility
|
|
81
|
+
*
|
|
82
|
+
* @param data - String to hash
|
|
83
|
+
* @returns SHA-256 hash as hex string
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const hash = await hashSHA256('hello world');
|
|
88
|
+
* // 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9'
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
declare function hashSHA256(data: string): Promise<string>;
|
|
92
|
+
/**
|
|
93
|
+
* Hash a string using SHA-512
|
|
94
|
+
*
|
|
95
|
+
* @param data - String to hash
|
|
96
|
+
* @returns SHA-512 hash as hex string
|
|
97
|
+
*/
|
|
98
|
+
declare function hashSHA512(data: string): Promise<string>;
|
|
99
|
+
/**
|
|
100
|
+
* Hash a string using MD5 (NOT SECURE - use for checksums only)
|
|
101
|
+
*
|
|
102
|
+
* @deprecated MD5 is cryptographically broken. Use SHA-256 for security-sensitive hashing.
|
|
103
|
+
* @param data - String to hash
|
|
104
|
+
* @returns MD5 hash as hex string
|
|
105
|
+
*/
|
|
106
|
+
declare function hashMD5(data: string): Promise<string>;
|
|
107
|
+
/**
|
|
108
|
+
* Hash password using bcrypt (requires bcryptjs)
|
|
109
|
+
*
|
|
110
|
+
* @param password - Password to hash
|
|
111
|
+
* @param rounds - Salt rounds (default: 10)
|
|
112
|
+
* @returns Bcrypt hash
|
|
113
|
+
*/
|
|
114
|
+
declare function hashBcrypt(password: string, rounds?: number): Promise<string>;
|
|
115
|
+
/**
|
|
116
|
+
* Verify password against bcrypt hash
|
|
117
|
+
*
|
|
118
|
+
* @param password - Password to verify
|
|
119
|
+
* @param hash - Bcrypt hash
|
|
120
|
+
* @returns true if password matches
|
|
121
|
+
*/
|
|
122
|
+
declare function verifyBcrypt(password: string, hash: string): Promise<boolean>;
|
|
123
|
+
/**
|
|
124
|
+
* Hash with HMAC-SHA256
|
|
125
|
+
*
|
|
126
|
+
* @param data - Data to hash
|
|
127
|
+
* @param key - Secret key
|
|
128
|
+
* @returns HMAC hash
|
|
129
|
+
*/
|
|
130
|
+
declare function hmacSHA256(data: string, key: string): Promise<string>;
|
|
131
|
+
/**
|
|
132
|
+
* Compare two strings in constant time (timing-safe)
|
|
133
|
+
* This prevents timing attacks that could leak information about the string contents.
|
|
134
|
+
*
|
|
135
|
+
* @param a - First string
|
|
136
|
+
* @param b - Second string
|
|
137
|
+
* @returns true if equal
|
|
138
|
+
*/
|
|
139
|
+
declare function timingSafeCompare(a: string, b: string): boolean;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Generate UUID v4 (random)
|
|
143
|
+
*
|
|
144
|
+
* @returns UUID v4 string
|
|
145
|
+
* @throws Error if crypto API is not available
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* generateUUID(); // '550e8400-e29b-41d4-a716-446655440000'
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
declare function generateUUID(): string;
|
|
153
|
+
/**
|
|
154
|
+
* Generate UUID v7 (time-sortable)
|
|
155
|
+
* Based on Unix Epoch timestamp
|
|
156
|
+
*
|
|
157
|
+
* @returns UUID v7 string
|
|
158
|
+
*/
|
|
159
|
+
declare function generateUUIDv7(): string;
|
|
160
|
+
/**
|
|
161
|
+
* Generate a secure random token
|
|
162
|
+
*
|
|
163
|
+
* @param length - Token length in bytes (default: 32)
|
|
164
|
+
* @returns Hex-encoded token
|
|
165
|
+
*/
|
|
166
|
+
declare function generateToken(length?: number): string;
|
|
167
|
+
/**
|
|
168
|
+
* Generate a cryptographically secure token
|
|
169
|
+
*
|
|
170
|
+
* @param length - Token length in bytes
|
|
171
|
+
* @returns Hex-encoded secure token
|
|
172
|
+
*/
|
|
173
|
+
declare function generateSecureToken(length?: number): string;
|
|
174
|
+
/**
|
|
175
|
+
* Generate a Base64 encoded token
|
|
176
|
+
*
|
|
177
|
+
* @param length - Token length in bytes
|
|
178
|
+
* @returns Base64-encoded token
|
|
179
|
+
*/
|
|
180
|
+
declare function generateBase64Token(length?: number): string;
|
|
181
|
+
/**
|
|
182
|
+
* Generate URL-safe token
|
|
183
|
+
*
|
|
184
|
+
* @param length - Token length
|
|
185
|
+
* @returns URL-safe token
|
|
186
|
+
*/
|
|
187
|
+
declare function generateUrlSafeToken(length?: number): string;
|
|
188
|
+
/**
|
|
189
|
+
* Validate UUID format
|
|
190
|
+
*
|
|
191
|
+
* @param uuid - String to validate
|
|
192
|
+
* @returns true if valid UUID
|
|
193
|
+
*/
|
|
194
|
+
declare function isValidUUID(uuid: string): boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Extract timestamp from UUID v7
|
|
197
|
+
*
|
|
198
|
+
* @param uuid - UUID v7 string
|
|
199
|
+
* @returns Date or null
|
|
200
|
+
*/
|
|
201
|
+
declare function getUUIDv7Timestamp(uuid: string): Date | null;
|
|
202
|
+
/**
|
|
203
|
+
* Generate short ID (8 characters)
|
|
204
|
+
*
|
|
205
|
+
* @returns Short ID
|
|
206
|
+
*/
|
|
207
|
+
declare function generateShortId(): string;
|
|
208
|
+
/**
|
|
209
|
+
* Generate nano ID style token
|
|
210
|
+
*
|
|
211
|
+
* @param length - Length (default: 21)
|
|
212
|
+
* @returns NanoID-style token
|
|
213
|
+
*/
|
|
214
|
+
declare function generateNanoId(length?: number): string;
|
|
215
|
+
|
|
216
|
+
export { type PasswordStrength, type PasswordStrengthOptions, checkPasswordStrength, generateBase64Token, generateNanoId, generateSecureToken, generateShortId, generateToken, generateUUID, generateUUIDv7, generateUrlSafeToken, getPasswordFeedback, getUUIDv7Timestamp, hashBcrypt, hashMD5, hashSHA256, hashSHA512, hmacSHA256, isStrongPassword, isValidUUID, meetsRequirements, timingSafeCompare, verifyBcrypt };
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Password strength result
|
|
3
|
+
*/
|
|
4
|
+
interface PasswordStrength {
|
|
5
|
+
/** Score from 0-4 (0 = very weak, 4 = very strong) */
|
|
6
|
+
score: 0 | 1 | 2 | 3 | 4;
|
|
7
|
+
/** Human-readable strength label */
|
|
8
|
+
label: 'very-weak' | 'weak' | 'fair' | 'strong' | 'very-strong';
|
|
9
|
+
/** Improvement suggestions */
|
|
10
|
+
suggestions: string[];
|
|
11
|
+
/** Requirements met */
|
|
12
|
+
requirements: {
|
|
13
|
+
minLength: boolean;
|
|
14
|
+
hasUppercase: boolean;
|
|
15
|
+
hasLowercase: boolean;
|
|
16
|
+
hasNumber: boolean;
|
|
17
|
+
hasSymbol: boolean;
|
|
18
|
+
noCommonPatterns: boolean;
|
|
19
|
+
};
|
|
20
|
+
/** Estimated crack time description */
|
|
21
|
+
crackTime: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Password strength options
|
|
25
|
+
*/
|
|
26
|
+
interface PasswordStrengthOptions {
|
|
27
|
+
/** Minimum length (default: 8) */
|
|
28
|
+
minLength?: number;
|
|
29
|
+
/** Require uppercase (default: true) */
|
|
30
|
+
requireUppercase?: boolean;
|
|
31
|
+
/** Require lowercase (default: true) */
|
|
32
|
+
requireLowercase?: boolean;
|
|
33
|
+
/** Require number (default: true) */
|
|
34
|
+
requireNumber?: boolean;
|
|
35
|
+
/** Require symbol (default: false) */
|
|
36
|
+
requireSymbol?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Check password strength
|
|
40
|
+
*
|
|
41
|
+
* @param password - Password to check
|
|
42
|
+
* @param options - Strength options
|
|
43
|
+
* @returns Password strength result
|
|
44
|
+
* @since 1.0.0
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const result = checkPasswordStrength('MyP@ssw0rd!');
|
|
49
|
+
* console.log(result.score); // 4
|
|
50
|
+
* console.log(result.label); // 'very-strong'
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
declare function checkPasswordStrength(password: string, options?: PasswordStrengthOptions): PasswordStrength;
|
|
54
|
+
/**
|
|
55
|
+
* Check if password meets requirements
|
|
56
|
+
*
|
|
57
|
+
* @param password - Password to check
|
|
58
|
+
* @param requirements - Requirements to check
|
|
59
|
+
* @returns true if all requirements met
|
|
60
|
+
*/
|
|
61
|
+
declare function meetsRequirements(password: string, requirements: Partial<PasswordStrengthOptions>): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Check if password is strong enough
|
|
64
|
+
*
|
|
65
|
+
* @param password - Password to check
|
|
66
|
+
* @param minScore - Minimum score (default: 3)
|
|
67
|
+
* @returns true if strong enough
|
|
68
|
+
*/
|
|
69
|
+
declare function isStrongPassword(password: string, minScore?: number): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Get password feedback message
|
|
72
|
+
*
|
|
73
|
+
* @param password - Password to check
|
|
74
|
+
* @returns Feedback message
|
|
75
|
+
*/
|
|
76
|
+
declare function getPasswordFeedback(password: string): string;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Hash a string using SHA-256
|
|
80
|
+
* Uses Web Crypto API for browser compatibility
|
|
81
|
+
*
|
|
82
|
+
* @param data - String to hash
|
|
83
|
+
* @returns SHA-256 hash as hex string
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const hash = await hashSHA256('hello world');
|
|
88
|
+
* // 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9'
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
declare function hashSHA256(data: string): Promise<string>;
|
|
92
|
+
/**
|
|
93
|
+
* Hash a string using SHA-512
|
|
94
|
+
*
|
|
95
|
+
* @param data - String to hash
|
|
96
|
+
* @returns SHA-512 hash as hex string
|
|
97
|
+
*/
|
|
98
|
+
declare function hashSHA512(data: string): Promise<string>;
|
|
99
|
+
/**
|
|
100
|
+
* Hash a string using MD5 (NOT SECURE - use for checksums only)
|
|
101
|
+
*
|
|
102
|
+
* @deprecated MD5 is cryptographically broken. Use SHA-256 for security-sensitive hashing.
|
|
103
|
+
* @param data - String to hash
|
|
104
|
+
* @returns MD5 hash as hex string
|
|
105
|
+
*/
|
|
106
|
+
declare function hashMD5(data: string): Promise<string>;
|
|
107
|
+
/**
|
|
108
|
+
* Hash password using bcrypt (requires bcryptjs)
|
|
109
|
+
*
|
|
110
|
+
* @param password - Password to hash
|
|
111
|
+
* @param rounds - Salt rounds (default: 10)
|
|
112
|
+
* @returns Bcrypt hash
|
|
113
|
+
*/
|
|
114
|
+
declare function hashBcrypt(password: string, rounds?: number): Promise<string>;
|
|
115
|
+
/**
|
|
116
|
+
* Verify password against bcrypt hash
|
|
117
|
+
*
|
|
118
|
+
* @param password - Password to verify
|
|
119
|
+
* @param hash - Bcrypt hash
|
|
120
|
+
* @returns true if password matches
|
|
121
|
+
*/
|
|
122
|
+
declare function verifyBcrypt(password: string, hash: string): Promise<boolean>;
|
|
123
|
+
/**
|
|
124
|
+
* Hash with HMAC-SHA256
|
|
125
|
+
*
|
|
126
|
+
* @param data - Data to hash
|
|
127
|
+
* @param key - Secret key
|
|
128
|
+
* @returns HMAC hash
|
|
129
|
+
*/
|
|
130
|
+
declare function hmacSHA256(data: string, key: string): Promise<string>;
|
|
131
|
+
/**
|
|
132
|
+
* Compare two strings in constant time (timing-safe)
|
|
133
|
+
* This prevents timing attacks that could leak information about the string contents.
|
|
134
|
+
*
|
|
135
|
+
* @param a - First string
|
|
136
|
+
* @param b - Second string
|
|
137
|
+
* @returns true if equal
|
|
138
|
+
*/
|
|
139
|
+
declare function timingSafeCompare(a: string, b: string): boolean;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Generate UUID v4 (random)
|
|
143
|
+
*
|
|
144
|
+
* @returns UUID v4 string
|
|
145
|
+
* @throws Error if crypto API is not available
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* generateUUID(); // '550e8400-e29b-41d4-a716-446655440000'
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
declare function generateUUID(): string;
|
|
153
|
+
/**
|
|
154
|
+
* Generate UUID v7 (time-sortable)
|
|
155
|
+
* Based on Unix Epoch timestamp
|
|
156
|
+
*
|
|
157
|
+
* @returns UUID v7 string
|
|
158
|
+
*/
|
|
159
|
+
declare function generateUUIDv7(): string;
|
|
160
|
+
/**
|
|
161
|
+
* Generate a secure random token
|
|
162
|
+
*
|
|
163
|
+
* @param length - Token length in bytes (default: 32)
|
|
164
|
+
* @returns Hex-encoded token
|
|
165
|
+
*/
|
|
166
|
+
declare function generateToken(length?: number): string;
|
|
167
|
+
/**
|
|
168
|
+
* Generate a cryptographically secure token
|
|
169
|
+
*
|
|
170
|
+
* @param length - Token length in bytes
|
|
171
|
+
* @returns Hex-encoded secure token
|
|
172
|
+
*/
|
|
173
|
+
declare function generateSecureToken(length?: number): string;
|
|
174
|
+
/**
|
|
175
|
+
* Generate a Base64 encoded token
|
|
176
|
+
*
|
|
177
|
+
* @param length - Token length in bytes
|
|
178
|
+
* @returns Base64-encoded token
|
|
179
|
+
*/
|
|
180
|
+
declare function generateBase64Token(length?: number): string;
|
|
181
|
+
/**
|
|
182
|
+
* Generate URL-safe token
|
|
183
|
+
*
|
|
184
|
+
* @param length - Token length
|
|
185
|
+
* @returns URL-safe token
|
|
186
|
+
*/
|
|
187
|
+
declare function generateUrlSafeToken(length?: number): string;
|
|
188
|
+
/**
|
|
189
|
+
* Validate UUID format
|
|
190
|
+
*
|
|
191
|
+
* @param uuid - String to validate
|
|
192
|
+
* @returns true if valid UUID
|
|
193
|
+
*/
|
|
194
|
+
declare function isValidUUID(uuid: string): boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Extract timestamp from UUID v7
|
|
197
|
+
*
|
|
198
|
+
* @param uuid - UUID v7 string
|
|
199
|
+
* @returns Date or null
|
|
200
|
+
*/
|
|
201
|
+
declare function getUUIDv7Timestamp(uuid: string): Date | null;
|
|
202
|
+
/**
|
|
203
|
+
* Generate short ID (8 characters)
|
|
204
|
+
*
|
|
205
|
+
* @returns Short ID
|
|
206
|
+
*/
|
|
207
|
+
declare function generateShortId(): string;
|
|
208
|
+
/**
|
|
209
|
+
* Generate nano ID style token
|
|
210
|
+
*
|
|
211
|
+
* @param length - Length (default: 21)
|
|
212
|
+
* @returns NanoID-style token
|
|
213
|
+
*/
|
|
214
|
+
declare function generateNanoId(length?: number): string;
|
|
215
|
+
|
|
216
|
+
export { type PasswordStrength, type PasswordStrengthOptions, checkPasswordStrength, generateBase64Token, generateNanoId, generateSecureToken, generateShortId, generateToken, generateUUID, generateUUIDv7, generateUrlSafeToken, getPasswordFeedback, getUUIDv7Timestamp, hashBcrypt, hashMD5, hashSHA256, hashSHA512, hmacSHA256, isStrongPassword, isValidUUID, meetsRequirements, timingSafeCompare, verifyBcrypt };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { checkPasswordStrength, generateBase64Token, generateNanoId, generateSecureToken, generateShortId, generateToken, generateUUID, generateUUIDv7, generateUrlSafeToken, getPasswordFeedback, getUUIDv7Timestamp, hashBcrypt, hashMD5, hashSHA256, hashSHA512, hmacSHA256, isStrongPassword, isValidUUID, meetsRequirements, timingSafeCompare, verifyBcrypt } from '../chunk-SD6P3WEJ.js';
|
|
2
|
+
import '../chunk-ETWGPOPY.js';
|
|
3
|
+
import '../chunk-4CV4JOE5.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkC75J62CV_cjs = require('../chunk-C75J62CV.cjs');
|
|
4
|
+
require('../chunk-CZLDE2OZ.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "capitalize", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkC75J62CV_cjs.capitalize; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ellipsis", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkC75J62CV_cjs.ellipsis; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "generateBase64String", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunkC75J62CV_cjs.generateBase64String; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "generateHexString", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return chunkC75J62CV_cjs.generateHexString; }
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "generateOTP", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return chunkC75J62CV_cjs.generateOTP; }
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports, "generatePassphrase", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () { return chunkC75J62CV_cjs.generatePassphrase; }
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "generatePassword", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () { return chunkC75J62CV_cjs.generatePassword; }
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "generateRandomString", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () { return chunkC75J62CV_cjs.generateRandomString; }
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(exports, "generateUrlSafeString", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
get: function () { return chunkC75J62CV_cjs.generateUrlSafeString; }
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(exports, "isValidSlug", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () { return chunkC75J62CV_cjs.isValidSlug; }
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "maskCreditCard", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () { return chunkC75J62CV_cjs.maskCreditCard; }
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(exports, "maskEmail", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function () { return chunkC75J62CV_cjs.maskEmail; }
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(exports, "maskIP", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function () { return chunkC75J62CV_cjs.maskIP; }
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "maskName", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () { return chunkC75J62CV_cjs.maskName; }
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(exports, "maskPhone", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function () { return chunkC75J62CV_cjs.maskPhone; }
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(exports, "maskString", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function () { return chunkC75J62CV_cjs.maskString; }
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "needsTruncation", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () { return chunkC75J62CV_cjs.needsTruncation; }
|
|
75
|
+
});
|
|
76
|
+
Object.defineProperty(exports, "slugify", {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () { return chunkC75J62CV_cjs.slugify; }
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(exports, "swapCase", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function () { return chunkC75J62CV_cjs.swapCase; }
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "toCamelCase", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () { return chunkC75J62CV_cjs.toCamelCase; }
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(exports, "toConstantCase", {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
get: function () { return chunkC75J62CV_cjs.toConstantCase; }
|
|
91
|
+
});
|
|
92
|
+
Object.defineProperty(exports, "toDotCase", {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
get: function () { return chunkC75J62CV_cjs.toDotCase; }
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(exports, "toKebabCase", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function () { return chunkC75J62CV_cjs.toKebabCase; }
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(exports, "toPascalCase", {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
get: function () { return chunkC75J62CV_cjs.toPascalCase; }
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(exports, "toSentenceCase", {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
get: function () { return chunkC75J62CV_cjs.toSentenceCase; }
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(exports, "toSlug", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function () { return chunkC75J62CV_cjs.toSlug; }
|
|
111
|
+
});
|
|
112
|
+
Object.defineProperty(exports, "toSnakeCase", {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
get: function () { return chunkC75J62CV_cjs.toSnakeCase; }
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(exports, "toTitleCase", {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
get: function () { return chunkC75J62CV_cjs.toTitleCase; }
|
|
119
|
+
});
|
|
120
|
+
Object.defineProperty(exports, "transliterate", {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () { return chunkC75J62CV_cjs.transliterate; }
|
|
123
|
+
});
|
|
124
|
+
Object.defineProperty(exports, "truncate", {
|
|
125
|
+
enumerable: true,
|
|
126
|
+
get: function () { return chunkC75J62CV_cjs.truncate; }
|
|
127
|
+
});
|
|
128
|
+
Object.defineProperty(exports, "truncateFilename", {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
get: function () { return chunkC75J62CV_cjs.truncateFilename; }
|
|
131
|
+
});
|
|
132
|
+
Object.defineProperty(exports, "truncateHtml", {
|
|
133
|
+
enumerable: true,
|
|
134
|
+
get: function () { return chunkC75J62CV_cjs.truncateHtml; }
|
|
135
|
+
});
|
|
136
|
+
Object.defineProperty(exports, "truncateSentences", {
|
|
137
|
+
enumerable: true,
|
|
138
|
+
get: function () { return chunkC75J62CV_cjs.truncateSentences; }
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(exports, "truncateWords", {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
get: function () { return chunkC75J62CV_cjs.truncateWords; }
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(exports, "uncapitalize", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function () { return chunkC75J62CV_cjs.uncapitalize; }
|
|
147
|
+
});
|
|
148
|
+
Object.defineProperty(exports, "uniqueSlug", {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
get: function () { return chunkC75J62CV_cjs.uniqueSlug; }
|
|
151
|
+
});
|
|
152
|
+
//# sourceMappingURL=index.cjs.map
|
|
153
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|