(raw: unknown, origin: string)
| 82 | // or in-use explicit config fails loud. |
| 83 | |
| 84 | function parsePort(raw: unknown, origin: string): number { |
| 85 | const n = typeof raw === 'number' ? raw : Number(raw) |
| 86 | if (!Number.isInteger(n) || n < 1 || n > 65535) { |
| 87 | throw new Error(`[guardian] invalid port ${JSON.stringify(raw)} from ${origin} — expected an integer in 1..65535`) |
| 88 | } |
| 89 | return n |
| 90 | } |
| 91 | |
| 92 | async function readPortsFile(userDataHome: string): Promise<Partial<Record<'web' | 'mcp' | 'uta', number>>> { |
| 93 | const filePath = resolve(userDataHome, 'data', 'config', 'ports.json') |
no outgoing calls
no test coverage detected