(options: {
stateDir: string;
provider: string;
profile: RemoteConfigProfile;
})
| 14 | const GENERATED_REMOTE_CONFIG_SECRET_KEYS = new Set(['daemonAuthToken', 'metroBearerToken']); |
| 15 | |
| 16 | export 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 | |
| 37 | function resolveGeneratedRemoteConfigProfile(options: { |
| 38 | configPath: string; |
no test coverage detected