UNPKG

@das3mical/adonis-mercure

Version:

A simple AdonisJS provider to interact with Mercure hub

12 lines (11 loc) 535 B
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; }