import https from 'https'; /** Fetches a URL over HTTPS and resolves with the response body as a string. */ export function httpsFetch(url: string): Promise { return new Promise((resolve, reject) => { https .get(url, (res) => { if (res.statusCode !== 200) { reject(new Error(`HTTP ${String(res.statusCode)} for ${url}`)); res.resume(); return; } const chunks: Buffer[] = []; res.on('data', (chunk: Buffer) => chunks.push(chunk)); res.on('end', () => resolve(Buffer.concat(chunks).toString('utf-8'))); res.on('error', reject); }) .on('error', reject); }); }