@veloxts/auth 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,10 +9,11 @@ Authentication and authorization system for VeloxTS Framework.
9
9
  - **Pluggable Auth Adapters** - Integrate external providers like BetterAuth, Clerk, Auth0
10
10
  - **Session Management** - Cookie-based sessions with pluggable storage backends
11
11
  - **JWT Authentication** - Stateless token-based authentication with refresh tokens
12
- - **Password Hashing** - Secure bcrypt hashing with configurable cost factors
13
- - **CSRF Protection** - Signed double-submit cookie pattern
12
+ - **Password Hashing** - Secure bcrypt/argon2 hashing with configurable cost factors
13
+ - **Password Policy** - Configurable strength requirements and breach detection
14
+ - **CSRF Protection** - Signed double-submit cookie pattern with timing-safe validation
14
15
  - **Guards and Policies** - Declarative authorization for procedures
15
- - **Rate Limiting** - Built-in request rate limiting middleware
16
+ - **Rate Limiting** - Auth-specific rate limiting with progressive backoff and lockout detection
16
17
 
17
18
  ## Table of Contents
18
19
 
package/dist/index.d.ts CHANGED
@@ -32,4 +32,6 @@ export type { AdapterAuthContext, AdapterHttpMethod, AdapterMiddlewareOptions, A
32
32
  export { AuthAdapterError, BaseAuthAdapter, createAdapterAuthMiddleware, createAuthAdapterPlugin, defineAuthAdapter, isAuthAdapter, } from './adapter.js';
33
33
  export type { BetterAuthAdapterConfig, BetterAuthApi, BetterAuthHandler, BetterAuthInstance, BetterAuthSession, BetterAuthSessionResult, BetterAuthUser, } from './adapters/better-auth.js';
34
34
  export { BetterAuthAdapter, createBetterAuthAdapter } from './adapters/better-auth.js';
35
+ export type { PasswordPolicyConfig, PasswordValidationResult, UserInfo, } from './password-policy.js';
36
+ export { checkPasswordBreach, checkPasswordStrength, createPasswordPolicy, isCommonPassword, PasswordPolicy, passwordPolicy, PasswordStrength, } from './password-policy.js';
35
37
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot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,uBAAuB,EACvB,cAAc,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAMvF,YAAY,EACV,oBAAoB,EACpB,wBAAwB,EACxB,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EAErB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EAEd,cAAc,EACd,gBAAgB,GACjB,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -97,4 +97,9 @@ createAdapterAuthMiddleware, createAuthAdapterPlugin, defineAuthAdapter,
97
97
  // Type guard
98
98
  isAuthAdapter, } from './adapter.js';
99
99
  export { BetterAuthAdapter, createBetterAuthAdapter } from './adapters/better-auth.js';
100
+ export { checkPasswordBreach, checkPasswordStrength,
101
+ // Legacy (deprecated)
102
+ createPasswordPolicy, isCommonPassword, PasswordPolicy,
103
+ // Succinct API
104
+ passwordPolicy, PasswordStrength, } from './password-policy.js';
100
105
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA6B3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAOvC,OAAO,EACL,wBAAwB;AACxB,sBAAsB;AACtB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,UAAU;AACV,eAAe;AACf,UAAU,EACV,kBAAkB;AAClB,sBAAsB;AACtB,uBAAuB,GACxB,MAAM,UAAU,CAAC;AAElB,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,OAAO;AACL,sBAAsB;AACtB,oBAAoB,EACpB,YAAY,EACZ,cAAc;AACd,eAAe;AAC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EACtB,YAAY,EACZ,aAAa;AACb,eAAe;AACf,iBAAiB,GAClB,MAAM,cAAc,CAAC;AA4BtB,OAAO;AACL,cAAc;AACd,gBAAgB;AAChB,sBAAsB;AACtB,eAAe;AACf,oBAAoB;AACpB,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB;AACjB,aAAa;AACb,aAAa,GACd,MAAM,cAAc,CAAC;AAetB,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA6B3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAOvC,OAAO,EACL,wBAAwB;AACxB,sBAAsB;AACtB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,UAAU;AACV,eAAe;AACf,UAAU,EACV,kBAAkB;AAClB,sBAAsB;AACtB,uBAAuB,GACxB,MAAM,UAAU,CAAC;AAElB,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,OAAO;AACL,sBAAsB;AACtB,oBAAoB,EACpB,YAAY,EACZ,cAAc;AACd,eAAe;AACf,cAAc,EACd,cAAc,GACf,MAAM,WAAW,CAAC;AAEnB,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,OAAO;AACL,cAAc;AACd,KAAK,EACL,KAAK;AACL,kBAAkB;AAClB,aAAa;AACb,oBAAoB;AACpB,WAAW,EACX,aAAa;AACb,YAAY;AACZ,YAAY,EACZ,aAAa,EACb,KAAK,EACL,gBAAgB,EAChB,aAAa,EACb,OAAO,EACP,GAAG,EACH,OAAO,GACR,MAAM,aAAa,CAAC;AAErB,+EAA+E;AAC/E,WAAW;AACX,+EAA+E;AAE/E,OAAO,EACL,SAAS;AACT,uBAAuB;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B,cAAc;AACd,eAAe;AACf,cAAc,EACd,gBAAgB,GACjB,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,259 @@
1
+ /**
2
+ * Password policy validation and strength scoring
3
+ *
4
+ * Provides configurable password requirements, strength scoring,
5
+ * common password checking, and optional breach detection.
6
+ *
7
+ * @module auth/password-policy
8
+ */
9
+ /**
10
+ * Password policy requirements configuration
11
+ */
12
+ export interface PasswordPolicyConfig {
13
+ /**
14
+ * Minimum password length
15
+ * @default 12
16
+ */
17
+ minLength?: number;
18
+ /**
19
+ * Maximum password length (0 for no limit)
20
+ * @default 128
21
+ */
22
+ maxLength?: number;
23
+ /**
24
+ * Require at least one uppercase letter
25
+ * @default false
26
+ */
27
+ requireUppercase?: boolean;
28
+ /**
29
+ * Require at least one lowercase letter
30
+ * @default false
31
+ */
32
+ requireLowercase?: boolean;
33
+ /**
34
+ * Require at least one digit
35
+ * @default false
36
+ */
37
+ requireDigits?: boolean;
38
+ /**
39
+ * Require at least one special character
40
+ * @default false
41
+ */
42
+ requireSpecialChars?: boolean;
43
+ /**
44
+ * Custom special characters set
45
+ * @default "!@#$%^&*()_+-=[]{}|;:,.<>?"
46
+ */
47
+ specialChars?: string;
48
+ /**
49
+ * Disallow common passwords from list
50
+ * @default true
51
+ */
52
+ disallowCommon?: boolean;
53
+ /**
54
+ * Check password against Have I Been Pwned API
55
+ * @default false
56
+ */
57
+ checkBreaches?: boolean;
58
+ /**
59
+ * Maximum allowed occurrences in breaches (0 = any breach fails)
60
+ * @default 0
61
+ */
62
+ maxBreachOccurrences?: number;
63
+ /**
64
+ * Custom password blacklist
65
+ * @default []
66
+ */
67
+ blacklist?: readonly string[];
68
+ /**
69
+ * Disallow passwords containing user information
70
+ * (email, username, etc. - must be provided during validation)
71
+ * @default true
72
+ */
73
+ disallowUserInfo?: boolean;
74
+ }
75
+ /**
76
+ * Password strength levels
77
+ */
78
+ export declare enum PasswordStrength {
79
+ VeryWeak = 0,
80
+ Weak = 1,
81
+ Fair = 2,
82
+ Strong = 3,
83
+ VeryStrong = 4
84
+ }
85
+ /**
86
+ * Password validation result
87
+ */
88
+ export interface PasswordValidationResult {
89
+ /** Whether password passes all requirements */
90
+ valid: boolean;
91
+ /** Validation error messages */
92
+ errors: string[];
93
+ /** Password strength score (0-4) */
94
+ strength: PasswordStrength;
95
+ /** Detailed strength score (0-100) */
96
+ score: number;
97
+ /** Whether password was found in breach database */
98
+ breached?: boolean;
99
+ /** Number of times password appeared in breaches */
100
+ breachCount?: number;
101
+ }
102
+ /**
103
+ * User information for password validation
104
+ */
105
+ export interface UserInfo {
106
+ /** User's email address */
107
+ email?: string;
108
+ /** Username */
109
+ username?: string;
110
+ /** First name */
111
+ firstName?: string;
112
+ /** Last name */
113
+ lastName?: string;
114
+ /** Any other identifying information to exclude */
115
+ [key: string]: string | undefined;
116
+ }
117
+ /**
118
+ * Password policy validator and strength scorer
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * const policy = new PasswordPolicy({
123
+ * minLength: 12,
124
+ * requireUppercase: true,
125
+ * requireLowercase: true,
126
+ * requireDigits: true,
127
+ * checkBreaches: true,
128
+ * });
129
+ *
130
+ * // Validate password
131
+ * const result = await policy.validate('MyP@ssw0rd123', {
132
+ * email: 'user@example.com',
133
+ * });
134
+ *
135
+ * if (!result.valid) {
136
+ * console.log('Errors:', result.errors);
137
+ * }
138
+ *
139
+ * console.log('Strength:', PasswordStrength[result.strength]);
140
+ * console.log('Score:', result.score);
141
+ * ```
142
+ */
143
+ export declare class PasswordPolicy {
144
+ private readonly config;
145
+ constructor(config?: PasswordPolicyConfig);
146
+ /**
147
+ * Validate a password against the policy
148
+ *
149
+ * @param password - Password to validate
150
+ * @param userInfo - Optional user information to check against
151
+ * @returns Validation result with errors and strength score
152
+ */
153
+ validate(password: string, userInfo?: UserInfo): Promise<PasswordValidationResult>;
154
+ /**
155
+ * Calculate password strength score (0-100) and level (0-4)
156
+ *
157
+ * Based on:
158
+ * - Length
159
+ * - Character variety (uppercase, lowercase, digits, special)
160
+ * - Entropy
161
+ * - Pattern detection
162
+ */
163
+ calculateStrength(password: string): {
164
+ score: number;
165
+ strength: PasswordStrength;
166
+ };
167
+ /**
168
+ * Calculate Shannon entropy of password
169
+ */
170
+ private calculateEntropy;
171
+ /**
172
+ * Check if character types are well-mixed (not clustered)
173
+ */
174
+ private checkMixedPositions;
175
+ /**
176
+ * Check password against Have I Been Pwned API
177
+ *
178
+ * Uses k-anonymity: only sends first 5 chars of SHA-1 hash
179
+ * to protect password privacy.
180
+ *
181
+ * @returns Number of times password appears in breaches (0 = not found)
182
+ */
183
+ private checkBreaches;
184
+ /**
185
+ * Get password strength as human-readable string
186
+ */
187
+ getStrengthLabel(strength: PasswordStrength): string;
188
+ /**
189
+ * Get password strength color (for UI display)
190
+ */
191
+ getStrengthColor(strength: PasswordStrength): string;
192
+ }
193
+ /**
194
+ * Create a password policy validator (succinct API)
195
+ *
196
+ * @example
197
+ * ```typescript
198
+ * import { passwordPolicy } from '@veloxts/auth';
199
+ *
200
+ * const policy = passwordPolicy({
201
+ * minLength: 12,
202
+ * requireUppercase: true,
203
+ * requireDigits: true,
204
+ * });
205
+ *
206
+ * const result = await policy.validate('MyPassword123');
207
+ * ```
208
+ */
209
+ export declare function passwordPolicy(config?: PasswordPolicyConfig): PasswordPolicy;
210
+ /**
211
+ * Creates a password policy validator
212
+ *
213
+ * @deprecated Use `passwordPolicy()` instead. Will be removed in v0.9.
214
+ */
215
+ export declare const createPasswordPolicy: typeof passwordPolicy;
216
+ /**
217
+ * Quick password strength check (no policy validation)
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * import { checkPasswordStrength } from '@veloxts/auth';
222
+ *
223
+ * const { strength, score } = checkPasswordStrength('MyP@ssw0rd123');
224
+ * console.log(PasswordStrength[strength]); // "Strong"
225
+ * console.log(score); // 75
226
+ * ```
227
+ */
228
+ export declare function checkPasswordStrength(password: string): {
229
+ score: number;
230
+ strength: PasswordStrength;
231
+ };
232
+ /**
233
+ * Quick common password check
234
+ *
235
+ * @example
236
+ * ```typescript
237
+ * import { isCommonPassword } from '@veloxts/auth';
238
+ *
239
+ * if (isCommonPassword('password123')) {
240
+ * console.log('Please choose a more secure password');
241
+ * }
242
+ * ```
243
+ */
244
+ export declare function isCommonPassword(password: string): boolean;
245
+ /**
246
+ * Check password against Have I Been Pwned
247
+ *
248
+ * @example
249
+ * ```typescript
250
+ * import { checkPasswordBreach } from '@veloxts/auth';
251
+ *
252
+ * const count = await checkPasswordBreach('password123');
253
+ * if (count > 0) {
254
+ * console.log(`Found in ${count} breaches!`);
255
+ * }
256
+ * ```
257
+ */
258
+ export declare function checkPasswordBreach(password: string): Promise<number>;
259
+ //# sourceMappingURL=password-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"password-policy.d.ts","sourceRoot":"","sources":["../src/password-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAE9B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B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AEG;IACH,OAAO,CAAC,mBAAmB;IAyB3B;;;;;;;OAOG;YACW,aAAa;IA+B3B;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM;IAepD;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM;CAcrD;AAiBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,oBAAoB,GAAG,cAAc,CAE5E;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,uBAAiB,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,GACf;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,gBAAgB,CAAA;CAAE,CAG/C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAG3E"}
@@ -0,0 +1,529 @@
1
+ /**
2
+ * Password policy validation and strength scoring
3
+ *
4
+ * Provides configurable password requirements, strength scoring,
5
+ * common password checking, and optional breach detection.
6
+ *
7
+ * @module auth/password-policy
8
+ */
9
+ import { createHash } from 'node:crypto';
10
+ /**
11
+ * Password strength levels
12
+ */
13
+ export var PasswordStrength;
14
+ (function (PasswordStrength) {
15
+ PasswordStrength[PasswordStrength["VeryWeak"] = 0] = "VeryWeak";
16
+ PasswordStrength[PasswordStrength["Weak"] = 1] = "Weak";
17
+ PasswordStrength[PasswordStrength["Fair"] = 2] = "Fair";
18
+ PasswordStrength[PasswordStrength["Strong"] = 3] = "Strong";
19
+ PasswordStrength[PasswordStrength["VeryStrong"] = 4] = "VeryStrong";
20
+ })(PasswordStrength || (PasswordStrength = {}));
21
+ // ============================================================================
22
+ // Common Passwords List (Top 100)
23
+ // ============================================================================
24
+ /**
25
+ * Most common passwords to block (from NCSC/HaveIBeenPwned research)
26
+ */
27
+ const COMMON_PASSWORDS = new Set([
28
+ '123456',
29
+ 'password',
30
+ '12345678',
31
+ 'qwerty',
32
+ '123456789',
33
+ '12345',
34
+ '1234',
35
+ '111111',
36
+ '1234567',
37
+ 'dragon',
38
+ '123123',
39
+ 'baseball',
40
+ 'iloveyou',
41
+ '2000',
42
+ '2001',
43
+ '2002',
44
+ '2003',
45
+ '2004',
46
+ '2005',
47
+ 'trustno1',
48
+ 'monkey',
49
+ '1234567890',
50
+ 'master',
51
+ 'superman',
52
+ 'qwertyuiop',
53
+ '654321',
54
+ 'letmein',
55
+ 'football',
56
+ 'shadow',
57
+ 'michael',
58
+ 'jennifer',
59
+ '1111',
60
+ '2222',
61
+ '3333',
62
+ '4444',
63
+ '5555',
64
+ '6666',
65
+ '7777',
66
+ '8888',
67
+ '9999',
68
+ '0000',
69
+ 'abc123',
70
+ 'batman',
71
+ 'welcome',
72
+ 'sunshine',
73
+ 'princess',
74
+ 'password1',
75
+ 'password123',
76
+ 'admin',
77
+ 'login',
78
+ 'passw0rd',
79
+ 'qwerty123',
80
+ 'solo',
81
+ 'starwars',
82
+ 'whatever',
83
+ 'charlie',
84
+ 'donald',
85
+ 'freedom',
86
+ 'ginger',
87
+ 'jordan',
88
+ 'killer',
89
+ 'liverpool',
90
+ 'london',
91
+ 'michelle',
92
+ 'thomas',
93
+ 'trustno',
94
+ 'cheese',
95
+ 'coffee',
96
+ 'cookie',
97
+ 'pepper',
98
+ 'summer',
99
+ 'winter',
100
+ 'welcome1',
101
+ 'access',
102
+ 'lovely',
103
+ 'bailey',
104
+ 'orange',
105
+ 'ashley',
106
+ 'daniel',
107
+ 'monkey1',
108
+ 'purple',
109
+ 'rangers',
110
+ 'secret',
111
+ 'secret1',
112
+ 'test',
113
+ 'test123',
114
+ 'computer',
115
+ 'internet',
116
+ 'maverick',
117
+ 'matrix',
118
+ 'phoenix',
119
+ 'thunder',
120
+ 'zxcvbnm',
121
+ 'hello',
122
+ 'hello123',
123
+ ]);
124
+ // ============================================================================
125
+ // Password Policy Class
126
+ // ============================================================================
127
+ /**
128
+ * Password policy validator and strength scorer
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const policy = new PasswordPolicy({
133
+ * minLength: 12,
134
+ * requireUppercase: true,
135
+ * requireLowercase: true,
136
+ * requireDigits: true,
137
+ * checkBreaches: true,
138
+ * });
139
+ *
140
+ * // Validate password
141
+ * const result = await policy.validate('MyP@ssw0rd123', {
142
+ * email: 'user@example.com',
143
+ * });
144
+ *
145
+ * if (!result.valid) {
146
+ * console.log('Errors:', result.errors);
147
+ * }
148
+ *
149
+ * console.log('Strength:', PasswordStrength[result.strength]);
150
+ * console.log('Score:', result.score);
151
+ * ```
152
+ */
153
+ export class PasswordPolicy {
154
+ config;
155
+ constructor(config = {}) {
156
+ this.config = {
157
+ minLength: config.minLength ?? 12,
158
+ maxLength: config.maxLength ?? 128,
159
+ requireUppercase: config.requireUppercase ?? false,
160
+ requireLowercase: config.requireLowercase ?? false,
161
+ requireDigits: config.requireDigits ?? false,
162
+ requireSpecialChars: config.requireSpecialChars ?? false,
163
+ specialChars: config.specialChars ?? "!@#$%^&*()_+-=[]{}|;:,.<>?",
164
+ disallowCommon: config.disallowCommon ?? true,
165
+ checkBreaches: config.checkBreaches ?? false,
166
+ maxBreachOccurrences: config.maxBreachOccurrences ?? 0,
167
+ blacklist: config.blacklist ?? [],
168
+ disallowUserInfo: config.disallowUserInfo ?? true,
169
+ };
170
+ }
171
+ /**
172
+ * Validate a password against the policy
173
+ *
174
+ * @param password - Password to validate
175
+ * @param userInfo - Optional user information to check against
176
+ * @returns Validation result with errors and strength score
177
+ */
178
+ async validate(password, userInfo) {
179
+ const errors = [];
180
+ // Length requirements
181
+ if (password.length < this.config.minLength) {
182
+ errors.push(`Password must be at least ${this.config.minLength} characters long`);
183
+ }
184
+ if (this.config.maxLength > 0 && password.length > this.config.maxLength) {
185
+ errors.push(`Password must not exceed ${this.config.maxLength} characters`);
186
+ }
187
+ // Character requirements
188
+ if (this.config.requireUppercase && !/[A-Z]/.test(password)) {
189
+ errors.push('Password must contain at least one uppercase letter');
190
+ }
191
+ if (this.config.requireLowercase && !/[a-z]/.test(password)) {
192
+ errors.push('Password must contain at least one lowercase letter');
193
+ }
194
+ if (this.config.requireDigits && !/\d/.test(password)) {
195
+ errors.push('Password must contain at least one digit');
196
+ }
197
+ if (this.config.requireSpecialChars) {
198
+ const specialCharsRegex = new RegExp(`[${escapeRegex(this.config.specialChars)}]`);
199
+ if (!specialCharsRegex.test(password)) {
200
+ errors.push('Password must contain at least one special character');
201
+ }
202
+ }
203
+ // Common password check
204
+ if (this.config.disallowCommon) {
205
+ const lowerPassword = password.toLowerCase();
206
+ if (COMMON_PASSWORDS.has(lowerPassword)) {
207
+ errors.push('Password is too common and easily guessable');
208
+ }
209
+ }
210
+ // Custom blacklist check
211
+ if (this.config.blacklist.length > 0) {
212
+ const lowerPassword = password.toLowerCase();
213
+ for (const banned of this.config.blacklist) {
214
+ if (lowerPassword === banned.toLowerCase()) {
215
+ errors.push('Password is not allowed');
216
+ break;
217
+ }
218
+ }
219
+ }
220
+ // User information check
221
+ if (this.config.disallowUserInfo && userInfo) {
222
+ const lowerPassword = password.toLowerCase();
223
+ const infoValues = Object.values(userInfo).filter((v) => typeof v === 'string' && v.length > 0);
224
+ for (const value of infoValues) {
225
+ const lowerValue = value.toLowerCase();
226
+ // Check if password contains user info
227
+ if (lowerPassword.includes(lowerValue)) {
228
+ errors.push('Password must not contain personal information');
229
+ break;
230
+ }
231
+ // Check if password is similar to email username
232
+ if (value.includes('@')) {
233
+ const username = value.split('@')[0].toLowerCase();
234
+ if (username.length >= 3 && lowerPassword.includes(username)) {
235
+ errors.push('Password must not contain personal information');
236
+ break;
237
+ }
238
+ }
239
+ }
240
+ }
241
+ // Strength score
242
+ const { score, strength } = this.calculateStrength(password);
243
+ // Breach check (async)
244
+ let breached;
245
+ let breachCount;
246
+ if (this.config.checkBreaches) {
247
+ try {
248
+ breachCount = await this.checkBreaches(password);
249
+ breached = breachCount > this.config.maxBreachOccurrences;
250
+ if (breached) {
251
+ errors.push(`Password has been found in ${breachCount} data breaches and is not secure`);
252
+ }
253
+ }
254
+ catch (error) {
255
+ // Breach check failed - log but don't fail validation
256
+ console.warn('Password breach check failed:', error);
257
+ }
258
+ }
259
+ return {
260
+ valid: errors.length === 0,
261
+ errors,
262
+ strength,
263
+ score,
264
+ breached,
265
+ breachCount,
266
+ };
267
+ }
268
+ /**
269
+ * Calculate password strength score (0-100) and level (0-4)
270
+ *
271
+ * Based on:
272
+ * - Length
273
+ * - Character variety (uppercase, lowercase, digits, special)
274
+ * - Entropy
275
+ * - Pattern detection
276
+ */
277
+ calculateStrength(password) {
278
+ let score = 0;
279
+ // Length scoring (up to 30 points)
280
+ if (password.length >= 8)
281
+ score += 10;
282
+ if (password.length >= 12)
283
+ score += 10;
284
+ if (password.length >= 16)
285
+ score += 5;
286
+ if (password.length >= 20)
287
+ score += 5;
288
+ // Character variety (up to 40 points)
289
+ const hasLower = /[a-z]/.test(password);
290
+ const hasUpper = /[A-Z]/.test(password);
291
+ const hasDigit = /\d/.test(password);
292
+ const hasSpecial = /[^a-zA-Z0-9]/.test(password);
293
+ const varietyCount = [hasLower, hasUpper, hasDigit, hasSpecial].filter(Boolean).length;
294
+ score += varietyCount * 10;
295
+ // Entropy bonus (up to 20 points)
296
+ const entropy = this.calculateEntropy(password);
297
+ if (entropy >= 30)
298
+ score += 5;
299
+ if (entropy >= 40)
300
+ score += 5;
301
+ if (entropy >= 50)
302
+ score += 5;
303
+ if (entropy >= 60)
304
+ score += 5;
305
+ // Pattern penalties (up to -20 points)
306
+ if (/(.)\1{2,}/.test(password))
307
+ score -= 5; // Repeated characters (aaa, 111)
308
+ if (/^[a-z]+$/.test(password))
309
+ score -= 5; // Only lowercase
310
+ if (/^[A-Z]+$/.test(password))
311
+ score -= 5; // Only uppercase
312
+ if (/^\d+$/.test(password))
313
+ score -= 10; // Only digits
314
+ if (/^(012|123|234|345|456|567|678|789|890)/.test(password))
315
+ score -= 5; // Sequential
316
+ // Bonus for mixing character positions (up to 10 points)
317
+ const mixedPositions = this.checkMixedPositions(password);
318
+ if (mixedPositions)
319
+ score += 10;
320
+ // Ensure score is within bounds
321
+ score = Math.max(0, Math.min(100, score));
322
+ // Convert score to strength level
323
+ let strength;
324
+ if (score < 20)
325
+ strength = PasswordStrength.VeryWeak;
326
+ else if (score < 40)
327
+ strength = PasswordStrength.Weak;
328
+ else if (score < 60)
329
+ strength = PasswordStrength.Fair;
330
+ else if (score < 80)
331
+ strength = PasswordStrength.Strong;
332
+ else
333
+ strength = PasswordStrength.VeryStrong;
334
+ return { score, strength };
335
+ }
336
+ /**
337
+ * Calculate Shannon entropy of password
338
+ */
339
+ calculateEntropy(password) {
340
+ const charCounts = new Map();
341
+ for (const char of password) {
342
+ charCounts.set(char, (charCounts.get(char) ?? 0) + 1);
343
+ }
344
+ let entropy = 0;
345
+ const length = password.length;
346
+ for (const count of charCounts.values()) {
347
+ const probability = count / length;
348
+ entropy -= probability * Math.log2(probability);
349
+ }
350
+ return entropy * length;
351
+ }
352
+ /**
353
+ * Check if character types are well-mixed (not clustered)
354
+ */
355
+ checkMixedPositions(password) {
356
+ if (password.length < 4)
357
+ return false;
358
+ const quarters = [
359
+ password.slice(0, Math.floor(password.length / 4)),
360
+ password.slice(Math.floor(password.length / 4), Math.floor(password.length / 2)),
361
+ password.slice(Math.floor(password.length / 2), Math.floor((3 * password.length) / 4)),
362
+ password.slice(Math.floor((3 * password.length) / 4)),
363
+ ];
364
+ // Check that each quarter has some variety
365
+ let varietyQuarters = 0;
366
+ for (const quarter of quarters) {
367
+ const hasAlpha = /[a-zA-Z]/.test(quarter);
368
+ const hasDigit = /\d/.test(quarter);
369
+ const hasSpecial = /[^a-zA-Z0-9]/.test(quarter);
370
+ if ([hasAlpha, hasDigit, hasSpecial].filter(Boolean).length >= 2) {
371
+ varietyQuarters++;
372
+ }
373
+ }
374
+ return varietyQuarters >= 3;
375
+ }
376
+ /**
377
+ * Check password against Have I Been Pwned API
378
+ *
379
+ * Uses k-anonymity: only sends first 5 chars of SHA-1 hash
380
+ * to protect password privacy.
381
+ *
382
+ * @returns Number of times password appears in breaches (0 = not found)
383
+ */
384
+ async checkBreaches(password) {
385
+ // Hash password with SHA-1
386
+ const hash = createHash('sha1').update(password).digest('hex').toUpperCase();
387
+ const prefix = hash.slice(0, 5);
388
+ const suffix = hash.slice(5);
389
+ // Query API with hash prefix
390
+ const response = await fetch(`https://api.pwnedpasswords.com/range/${prefix}`, {
391
+ headers: {
392
+ 'User-Agent': 'VeloxTS-Auth-Password-Policy',
393
+ },
394
+ });
395
+ if (!response.ok) {
396
+ throw new Error(`HaveIBeenPwned API error: ${response.status}`);
397
+ }
398
+ const text = await response.text();
399
+ const lines = text.split('\n');
400
+ // Search for our suffix in results
401
+ for (const line of lines) {
402
+ const [hashSuffix, countStr] = line.split(':');
403
+ if (hashSuffix === suffix) {
404
+ return parseInt(countStr.trim(), 10);
405
+ }
406
+ }
407
+ return 0; // Not found in breaches
408
+ }
409
+ /**
410
+ * Get password strength as human-readable string
411
+ */
412
+ getStrengthLabel(strength) {
413
+ switch (strength) {
414
+ case PasswordStrength.VeryWeak:
415
+ return 'Very Weak';
416
+ case PasswordStrength.Weak:
417
+ return 'Weak';
418
+ case PasswordStrength.Fair:
419
+ return 'Fair';
420
+ case PasswordStrength.Strong:
421
+ return 'Strong';
422
+ case PasswordStrength.VeryStrong:
423
+ return 'Very Strong';
424
+ }
425
+ }
426
+ /**
427
+ * Get password strength color (for UI display)
428
+ */
429
+ getStrengthColor(strength) {
430
+ switch (strength) {
431
+ case PasswordStrength.VeryWeak:
432
+ return '#d73a49'; // Red
433
+ case PasswordStrength.Weak:
434
+ return '#e36209'; // Orange
435
+ case PasswordStrength.Fair:
436
+ return '#ffd33d'; // Yellow
437
+ case PasswordStrength.Strong:
438
+ return '#28a745'; // Green
439
+ case PasswordStrength.VeryStrong:
440
+ return '#0366d6'; // Blue
441
+ }
442
+ }
443
+ }
444
+ // ============================================================================
445
+ // Helper Functions
446
+ // ============================================================================
447
+ /**
448
+ * Escape special characters for regex
449
+ */
450
+ function escapeRegex(str) {
451
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
452
+ }
453
+ // ============================================================================
454
+ // Convenience Exports
455
+ // ============================================================================
456
+ /**
457
+ * Create a password policy validator (succinct API)
458
+ *
459
+ * @example
460
+ * ```typescript
461
+ * import { passwordPolicy } from '@veloxts/auth';
462
+ *
463
+ * const policy = passwordPolicy({
464
+ * minLength: 12,
465
+ * requireUppercase: true,
466
+ * requireDigits: true,
467
+ * });
468
+ *
469
+ * const result = await policy.validate('MyPassword123');
470
+ * ```
471
+ */
472
+ export function passwordPolicy(config) {
473
+ return new PasswordPolicy(config);
474
+ }
475
+ /**
476
+ * Creates a password policy validator
477
+ *
478
+ * @deprecated Use `passwordPolicy()` instead. Will be removed in v0.9.
479
+ */
480
+ export const createPasswordPolicy = passwordPolicy;
481
+ /**
482
+ * Quick password strength check (no policy validation)
483
+ *
484
+ * @example
485
+ * ```typescript
486
+ * import { checkPasswordStrength } from '@veloxts/auth';
487
+ *
488
+ * const { strength, score } = checkPasswordStrength('MyP@ssw0rd123');
489
+ * console.log(PasswordStrength[strength]); // "Strong"
490
+ * console.log(score); // 75
491
+ * ```
492
+ */
493
+ export function checkPasswordStrength(password) {
494
+ const policy = new PasswordPolicy();
495
+ return policy.calculateStrength(password);
496
+ }
497
+ /**
498
+ * Quick common password check
499
+ *
500
+ * @example
501
+ * ```typescript
502
+ * import { isCommonPassword } from '@veloxts/auth';
503
+ *
504
+ * if (isCommonPassword('password123')) {
505
+ * console.log('Please choose a more secure password');
506
+ * }
507
+ * ```
508
+ */
509
+ export function isCommonPassword(password) {
510
+ return COMMON_PASSWORDS.has(password.toLowerCase());
511
+ }
512
+ /**
513
+ * Check password against Have I Been Pwned
514
+ *
515
+ * @example
516
+ * ```typescript
517
+ * import { checkPasswordBreach } from '@veloxts/auth';
518
+ *
519
+ * const count = await checkPasswordBreach('password123');
520
+ * if (count > 0) {
521
+ * console.log(`Found in ${count} breaches!`);
522
+ * }
523
+ * ```
524
+ */
525
+ export async function checkPasswordBreach(password) {
526
+ const policy = new PasswordPolicy();
527
+ return policy['checkBreaches'](password);
528
+ }
529
+ //# sourceMappingURL=password-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"password-policy.js","sourceRoot":"","sources":["../src/password-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAoFzC;;GAEG;AACH,MAAM,CAAN,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC1B,+DAAY,CAAA;IACZ,uDAAQ,CAAA;IACR,uDAAQ,CAAA;IACR,2DAAU,CAAA;IACV,mEAAc,CAAA;AAChB,CAAC,EANW,gBAAgB,KAAhB,gBAAgB,QAM3B;AA6CD,+EAA+E;AAC/E,kCAAkC;AAClC,+EAA+E;AAE/E;;GAEG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC/B,QAAQ;IACR,UAAU;IACV,UAAU;IACV,QAAQ;IACR,WAAW;IACX,OAAO;IACP,MAAM;IACN,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,UAAU;IACV,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,UAAU;IACV,QAAQ;IACR,YAAY;IACZ,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,QAAQ;IACR,SAAS;IACT,UAAU;IACV,QAAQ;IACR,SAAS;IACT,UAAU;IACV,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,QAAQ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e,CAAC,CAAC,QAAQ,CAAC,CAAC;AAC3C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/auth",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Authentication and authorization system for VeloxTS framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -42,8 +42,8 @@
42
42
  "dependencies": {
43
43
  "@fastify/cookie": "11.0.2",
44
44
  "fastify": "5.6.2",
45
- "@veloxts/core": "0.3.5",
46
- "@veloxts/router": "0.3.5"
45
+ "@veloxts/core": "0.3.6",
46
+ "@veloxts/router": "0.3.6"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "argon2": ">=0.30.0",
@@ -67,8 +67,8 @@
67
67
  "fastify-plugin": "5.1.0",
68
68
  "typescript": "5.9.3",
69
69
  "vitest": "4.0.15",
70
- "@veloxts/testing": "0.0.1",
71
- "@veloxts/validation": "0.3.5"
70
+ "@veloxts/testing": "0.0.2",
71
+ "@veloxts/validation": "0.3.6"
72
72
  },
73
73
  "keywords": [
74
74
  "velox",