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

Function resolveProxyConnectProfile

src/cli/connection/proxy-profile.ts:10–60  ·  view source on GitHub ↗
(options: {
  flags: CliFlags;
  stateDir: string;
  cwd: string;
  env?: EnvMap;
})

Source from the content-addressed store, hash-verified

8import { resolveRequestedLeaseBackend } from '../commands/connection-runtime.ts';
9
10export function resolveProxyConnectProfile(options: {
11 flags: CliFlags;
12 stateDir: string;
13 cwd: string;
14 env?: EnvMap;
15}): { flags: CliFlags; remoteConfigPath: string } {
16 const daemonBaseUrl = options.flags.daemonBaseUrl ?? options.env?.AGENT_DEVICE_DAEMON_BASE_URL;
17 if (!daemonBaseUrl) {
18 throw new AppError(
19 'INVALID_ARGS',
20 'connect proxy requires --daemon-base-url <url> or AGENT_DEVICE_DAEMON_BASE_URL.',
21 );
22 }
23 const clientId = buildProxyClientId(options.stateDir, daemonBaseUrl, options.flags.session);
24 const profile: RemoteConfigProfile = {
25 daemonBaseUrl,
26 daemonTransport: options.flags.daemonTransport ?? 'http',
27 daemonServerMode: options.flags.daemonServerMode,
28 tenant: options.flags.tenant ?? 'proxy',
29 sessionIsolation: options.flags.sessionIsolation ?? 'tenant',
30 runId: options.flags.runId ?? `proxy-${clientId}`,
31 leaseProvider: 'proxy',
32 clientId,
33 leaseBackend: options.flags.leaseBackend ?? resolveRequestedLeaseBackend(options.flags),
34 platform: options.flags.platform,
35 target: options.flags.target,
36 device: options.flags.device,
37 udid: options.flags.udid,
38 serial: options.flags.serial,
39 iosSimulatorDeviceSet: options.flags.iosSimulatorDeviceSet,
40 androidDeviceAllowlist: options.flags.androidDeviceAllowlist,
41 session: options.flags.session,
42 // Secrets must never be persisted in the generated (non-secret) profile.
43 // Mirror the cloud path, which keeps daemonAuthToken in-memory only: the
44 // bearer token survives this connect via the returned flags below, and
45 // later commands re-supply it through AGENT_DEVICE_METRO_BEARER_TOKEN.
46 ...readMetroProfileFields(options.flags),
47 };
48 return persistAndResolveGeneratedProfile({
49 stateDir: options.stateDir,
50 provider: 'proxy',
51 profile,
52 cwd: options.cwd,
53 env: options.env,
54 flags: options.flags,
55 extraFlags: {
56 daemonBaseUrl,
57 daemonTransport: options.flags.daemonTransport ?? 'http',
58 },
59 });
60}
61
62function buildProxyClientId(
63 stateDir: string,

Callers 1

resolveConnectProfileFunction · 0.90

Calls 4

readMetroProfileFieldsFunction · 0.90
buildProxyClientIdFunction · 0.85

Tested by

no test coverage detected