Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript
972 B
Raw Blame
import { generateKeyPairSync } from 'node:crypto'

/**
 * Shared test fixture: real, randomly generated RSA keys for the three JWT
 * slots so config-dependent suites exercise the non-dev path without implicit
 * dev defaults and without writing to the local dev-key store. Tests that
 * verify missing-key failures delete these variables explicitly.
 */
function testKey(): string {
  return generateKeyPairSync('rsa', {
    modulusLength: 2048,
    privateKeyEncoding: { type: 'pkcs8', format: 'pem' },
    publicKeyEncoding: { type: 'spki', format: 'pem' },
  }).privateKey
}

const testKeys: Record<string, string> = {
  CONTROL_API_RPC_JWT_PRIVATE_KEY: testKey(),
  CONTROL_API_SESSION_JWT_PRIVATE_KEY: testKey(),
  CONTROL_API_ADMIN_JWT_PRIVATE_KEY: testKey(),
}

export const JWT_TEST_KEY_ENV_NAMES = Object.keys(testKeys) as readonly string[]

for (const [name, value] of Object.entries(testKeys)) {
  if (!process.env[name]) {
    process.env[name] = value
  }
}