@das3mical/adonis-mercure
Version:
Mercure Hub integration for AdonisJS v6 — publish real-time updates via Server-Sent Events (SSE)
12 lines (11 loc) • 535 B
JavaScript
import { MercureConfigError } from './errors/config_error.js';
const ALLOWED_ALGORITHMS = ['HS256', 'HS384', 'HS512', 'RS256', 'RS384', 'RS512'];
export function defineConfig(config) {
if (!ALLOWED_ALGORITHMS.includes(config.jwt.alg)) {
throw new MercureConfigError(`Algorithm "${config.jwt.alg}" is not allowed. Use one of: ${ALLOWED_ALGORITHMS.join(', ')}`);
}
if (config.jwt.secret.length < 32) {
throw new MercureConfigError('jwt.secret must be at least 32 characters long');
}
return config;
}