1import { CommandError } from '../utils/errors';
2import { fetchAsync } from './rest/client';
3
4export async function getExpoGoIntermediateCertificateAsync(easProjectId: string): Promise<string> {
5  const response = await fetchAsync(
6    `projects/${encodeURIComponent(
7      easProjectId
8    )}/development-certificates/expo-go-intermediate-certificate`,
9    {
10      method: 'GET',
11    }
12  );
13  if (!response.ok) {
14    throw new CommandError('API', `Unexpected error from Expo servers: ${response.statusText}.`);
15  }
16  const buffer = await response.buffer();
17  return buffer.toString('utf8');
18}
19