better-auth-studio 1.0.47-beta.16 → 1.0.47-beta.18

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.
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAOA,OAAO,EAA+B,MAAM,EAAE,MAAM,SAAS,CAAC;AAS9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA8D9C,wBAAsB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CA8I/E;AAwBD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAqmJR"}
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAOA,OAAO,EAA+B,MAAM,EAAE,MAAM,SAAS,CAAC;AAS9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA8D9C,wBAAsB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CA8I/E;AAwBD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAmvJR"}
package/dist/routes.js CHANGED
@@ -4356,6 +4356,146 @@ export function createRoutes(authConfig, configPath, geoDbPath) {
4356
4356
  });
4357
4357
  }
4358
4358
  });
4359
+ router.post('/api/tools/password-strength', async (req, res) => {
4360
+ try {
4361
+ const { password } = req.body || {};
4362
+ if (!password || typeof password !== 'string') {
4363
+ return res.status(400).json({ success: false, error: 'Password is required' });
4364
+ }
4365
+ const emailAndPassword = authConfig.emailAndPassword || {};
4366
+ const minLength = emailAndPassword?.minPasswordLength || 8;
4367
+ const maxLength = emailAndPassword?.maxPasswordLength || 128;
4368
+ const checks = [];
4369
+ let score = 0;
4370
+ // Length check
4371
+ const lengthCheck = password.length >= minLength && password.length <= maxLength;
4372
+ checks.push({
4373
+ name: 'Length',
4374
+ passed: lengthCheck,
4375
+ message: lengthCheck
4376
+ ? `Meets length requirement (${minLength}-${maxLength} chars)`
4377
+ : `Must be between ${minLength} and ${maxLength} characters`,
4378
+ });
4379
+ if (lengthCheck)
4380
+ score += 1;
4381
+ const minLengthCheck = password.length >= minLength;
4382
+ checks.push({
4383
+ name: 'Minimum Length',
4384
+ passed: minLengthCheck,
4385
+ message: minLengthCheck
4386
+ ? `At least ${minLength} characters`
4387
+ : `Must be at least ${minLength} characters`,
4388
+ });
4389
+ if (minLengthCheck && password.length >= 12)
4390
+ score += 0.5;
4391
+ const maxLengthCheck = password.length <= maxLength;
4392
+ checks.push({
4393
+ name: 'Maximum Length',
4394
+ passed: maxLengthCheck,
4395
+ message: maxLengthCheck
4396
+ ? `Within ${maxLength} character limit`
4397
+ : `Must not exceed ${maxLength} characters`,
4398
+ });
4399
+ // Uppercase check
4400
+ const hasUppercase = /[A-Z]/.test(password);
4401
+ checks.push({
4402
+ name: 'Uppercase Letter',
4403
+ passed: hasUppercase,
4404
+ message: hasUppercase ? 'Contains uppercase letter' : 'Missing uppercase letter',
4405
+ });
4406
+ if (hasUppercase)
4407
+ score += 0.5;
4408
+ // Lowercase check
4409
+ const hasLowercase = /[a-z]/.test(password);
4410
+ checks.push({
4411
+ name: 'Lowercase Letter',
4412
+ passed: hasLowercase,
4413
+ message: hasLowercase ? 'Contains lowercase letter' : 'Missing lowercase letter',
4414
+ });
4415
+ if (hasLowercase)
4416
+ score += 0.5;
4417
+ // Number check
4418
+ const hasNumber = /\d/.test(password);
4419
+ checks.push({
4420
+ name: 'Number',
4421
+ passed: hasNumber,
4422
+ message: hasNumber ? 'Contains number' : 'Missing number',
4423
+ });
4424
+ if (hasNumber)
4425
+ score += 0.5;
4426
+ // Special character check
4427
+ const hasSpecialChar = /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(password);
4428
+ checks.push({
4429
+ name: 'Special Character',
4430
+ passed: hasSpecialChar,
4431
+ message: hasSpecialChar ? 'Contains special character' : 'Missing special character',
4432
+ });
4433
+ if (hasSpecialChar)
4434
+ score += 0.5;
4435
+ // Common patterns check
4436
+ const commonPatterns = [
4437
+ /12345/,
4438
+ /password/i,
4439
+ /qwerty/i,
4440
+ /abc123/i,
4441
+ /admin/i,
4442
+ /letmein/i,
4443
+ ];
4444
+ const hasCommonPattern = commonPatterns.some((pattern) => pattern.test(password));
4445
+ checks.push({
4446
+ name: 'Common Pattern',
4447
+ passed: !hasCommonPattern,
4448
+ message: hasCommonPattern
4449
+ ? 'Contains common pattern (weak)'
4450
+ : 'No common patterns detected',
4451
+ });
4452
+ if (!hasCommonPattern)
4453
+ score += 0.5;
4454
+ // Entropy check (basic)
4455
+ const uniqueChars = new Set(password).size;
4456
+ const entropyCheck = uniqueChars >= password.length * 0.5;
4457
+ checks.push({
4458
+ name: 'Character Variety',
4459
+ passed: entropyCheck,
4460
+ message: entropyCheck
4461
+ ? 'Good character variety'
4462
+ : 'Low character variety (repetitive)',
4463
+ });
4464
+ if (entropyCheck)
4465
+ score += 0.5;
4466
+ // Determine strength
4467
+ const finalScore = Math.min(Math.round(score), 5);
4468
+ let strength;
4469
+ if (finalScore <= 1)
4470
+ strength = 'weak';
4471
+ else if (finalScore === 2)
4472
+ strength = 'fair';
4473
+ else if (finalScore === 3)
4474
+ strength = 'good';
4475
+ else if (finalScore === 4)
4476
+ strength = 'strong';
4477
+ else
4478
+ strength = 'very-strong';
4479
+ const meetsConfig = lengthCheck && minLengthCheck && maxLengthCheck;
4480
+ res.json({
4481
+ success: true,
4482
+ score: finalScore,
4483
+ strength,
4484
+ checks,
4485
+ meetsConfig,
4486
+ configRequirements: {
4487
+ minLength,
4488
+ maxLength,
4489
+ },
4490
+ });
4491
+ }
4492
+ catch (error) {
4493
+ res.status(500).json({
4494
+ success: false,
4495
+ error: error instanceof Error ? error.message : 'Failed to check password strength',
4496
+ });
4497
+ }
4498
+ });
4359
4499
  return router;
4360
4500
  }
4361
4501
  //# sourceMappingURL=routes.js.map