'use strict'; const path = require('path'); function bool(v, dflt) { if (v === undefined || v === '') return dflt; return /^(1|true|yes|on)$/i.test(String(v)); } function list(v) { return String(v || '') .split(',') .map((s) => s.trim().toLowerCase()) .filter(Boolean); } const config = { port: Number(process.env.PORT || 8080), host: process.env.HOST || '0.0.0.0', // garagedoor-node-ws central auth authUrl: (process.env.AUTH_URL || 'http://192.168.4.208:8000').replace(/\/$/, ''), // Admins: username allowlist, or garagedoor `level` at/above this threshold. adminUsers: list(process.env.ADMIN_USERS), adminLevel: process.env.ADMIN_LEVEL === '' || process.env.ADMIN_LEVEL === undefined ? null : Number(process.env.ADMIN_LEVEL), dbPath: process.env.DB_PATH || path.join(__dirname, '..', 'data', 'rcs.db'), // Key material for AES-256-GCM at-rest encryption of VNC passwords / agent keys. encryptionKey: process.env.ENCRYPTION_KEY || '', // Public base URL, used when rendering invite links. Falls back to the request host. publicUrl: (process.env.PUBLIC_URL || '').replace(/\/$/, ''), ticketTtlMs: Number(process.env.TICKET_TTL_MS || 30_000), inviteDefaultTtlMs: Number(process.env.INVITE_TTL_MS || 24 * 60 * 60 * 1000), agentOfflineAfterMs: Number(process.env.AGENT_OFFLINE_AFTER_MS || 90_000), consentTimeoutMs: Number(process.env.CONSENT_TIMEOUT_MS || 45_000), // Session invites let unauthenticated people connect. Off by default is safer, // but the whole point of this app is handing a link to someone, so: on. allowSessionInvites: bool(process.env.ALLOW_SESSION_INVITES, true), trustProxy: bool(process.env.TRUST_PROXY, true), logLevel: process.env.LOG_LEVEL || 'info', }; module.exports = config;