MCPcopy Index your code
hub / github.com/callstack/agent-device / fetchConnectionProfile

Function fetchConnectionProfile

src/cli/connection/cloud-profile.ts:64–80  ·  view source on GitHub ↗
(options: {
  cloudBaseUrl: string;
  accessToken: string;
  fetchImpl?: typeof fetch;
})

Source from the content-addressed store, hash-verified

62}
63
64async 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
82function parseConnectionProfile(value: unknown): RemoteConfigProfile {
83 if (!value || typeof value !== 'object' || Array.isArray(value)) {

Callers 1

Calls 2

fetchImplFunction · 0.85
parseConnectionProfileFunction · 0.85

Tested by

no test coverage detected