MCPcopy
hub / github.com/callstack/agent-device / writeGeneratedRemoteConfig

Function writeGeneratedRemoteConfig

src/cli/connection/generated-config.ts:16–35  ·  view source on GitHub ↗
(options: {
  stateDir: string;
  provider: string;
  profile: RemoteConfigProfile;
})

Source from the content-addressed store, hash-verified

14const GENERATED_REMOTE_CONFIG_SECRET_KEYS = new Set(['daemonAuthToken', 'metroBearerToken']);
15
16export function writeGeneratedRemoteConfig(options: {
17 stateDir: string;
18 provider: string;
19 profile: RemoteConfigProfile;
20}): string {
21 const normalized = normalizeJson(stripGeneratedProfileSecrets(options.profile));
22 const configDir = path.join(options.stateDir, 'remote-connections', 'generated');
23 fs.mkdirSync(configDir, { recursive: true, mode: 0o700 });
24 const configPath = path.join(
25 configDir,
26 `${safeProviderName(options.provider)}-${profileHash(normalized)}.json`,
27 );
28 fs.writeFileSync(configPath, `${JSON.stringify(normalized, null, 2)}\n`, { mode: 0o600 });
29 try {
30 fs.chmodSync(configPath, 0o600);
31 } catch {
32 // Best effort on filesystems that do not support POSIX mode bits.
33 }
34 return configPath;
35}
36
37function resolveGeneratedRemoteConfigProfile(options: {
38 configPath: string;

Calls 4

normalizeJsonFunction · 0.85
safeProviderNameFunction · 0.85
profileHashFunction · 0.85

Tested by

no test coverage detected