(options: {
cloudBaseUrl: string;
accessToken: string;
fetchImpl?: typeof fetch;
})
| 62 | } |
| 63 | |
| 64 | async function fetchConnectionProfile(options: { |
| 65 | cloudBaseUrl: string; |
| 66 | accessToken: string; |
| 67 | fetchImpl?: typeof fetch; |
| 68 | }): Promise<RemoteConfigProfile> { |
| 69 | const fetchImpl = options.fetchImpl ?? fetch; |
| 70 | const response = await fetchImpl(new URL(CONNECTION_PROFILE_PATH, options.cloudBaseUrl), { |
| 71 | method: 'GET', |
| 72 | headers: { authorization: `Bearer ${options.accessToken}` }, |
| 73 | signal: AbortSignal.timeout(HTTP_TIMEOUT_MS), |
| 74 | }); |
| 75 | const parsed = await readCloudJsonResponse<unknown>(response, { |
| 76 | invalidJsonMessage: `Cloud connection profile endpoint returned invalid JSON (${response.status}).`, |
| 77 | rejectedMessage: 'Cloud connection profile endpoint rejected the request.', |
| 78 | }); |
| 79 | return parseConnectionProfile(parsed); |
| 80 | } |
| 81 | |
| 82 | function parseConnectionProfile(value: unknown): RemoteConfigProfile { |
| 83 | if (!value || typeof value !== 'object' || Array.isArray(value)) { |
no test coverage detected