Files
miles c250653961 Add comprehensive test suite for application functionality
- Implement tests for HTTP API endpoints, ensuring correct responses and security headers.
- Create configuration tests to validate loading of defaults and environment overrides.
- Add tests for FEDL service to verify data handling and snapshot functionality.
- Introduce GitHub service tests to check API data normalization and caching behavior.
- Develop monitor service tests for network checks and uptime calculations.
- Implement persistence tests to ensure database migrations are idempotent and data persists across restarts.
- Add vault service tests for session management and brute-force protection mechanisms.
- Include helper functions for test context creation and JSON response handling.
2026-11-08 16:24:06 -06:00

35 lines
1.1 KiB
JavaScript

import argon2 from 'argon2';
import { ARGON2_OPTIONS } from '../services/vault.js';
function readStdin() {
return new Promise((resolve) => {
let data = '';
process.stdin.setEncoding('utf8');
process.stdin.on('data', (chunk) => { data += chunk; });
process.stdin.on('end', () => resolve(data.trim()));
process.stdin.resume();
});
}
const supplied = process.argv.slice(2).join(' ').trim();
const password = supplied || process.env.VAULT_PASSWORD || (await readStdin());
if (!password) {
console.error('Usage: npm run hash-password -- "your passphrase"');
console.error(' or: printf "your passphrase" | npm run hash-password');
process.exit(1);
}
if (password.length < 8) {
console.error('Refusing to hash a passphrase shorter than 8 characters.');
process.exit(1);
}
const hash = await argon2.hash(password, ARGON2_OPTIONS);
console.log('');
console.log('Add this line to .env on the server:');
console.log('');
console.log(`VAULT_PASSWORD_HASH=${hash}`);
console.log('');
console.log('Keep the passphrase out of shell history, git, and frontend files.');