UNPKG

longcelot-sheet-db

Version:

Google Sheets-backed staging database adapter for Node.js with schema-first design

36 lines 1.27 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.hashPassword = hashPassword; exports.comparePassword = comparePassword; exports.validatePasswordStrength = validatePasswordStrength; const bcryptjs_1 = __importDefault(require("bcryptjs")); const SALT_ROUNDS = 10; async function hashPassword(password) { return bcryptjs_1.default.hash(password, SALT_ROUNDS); } async function comparePassword(password, hash) { return bcryptjs_1.default.compare(password, hash); } function validatePasswordStrength(password) { const errors = []; if (password.length < 8) { errors.push('Password must be at least 8 characters long'); } if (!/[A-Z]/.test(password)) { errors.push('Password must contain at least one uppercase letter'); } if (!/[a-z]/.test(password)) { errors.push('Password must contain at least one lowercase letter'); } if (!/[0-9]/.test(password)) { errors.push('Password must contain at least one number'); } return { valid: errors.length === 0, errors, }; } //# sourceMappingURL=password.js.map