refactor: dedupe shared string aliases

This commit is contained in:
Peter Steinberger
2026-04-07 09:09:48 +01:00
parent f336d8c948
commit 9d8d1dd4c5
19 changed files with 88 additions and 177 deletions

View File

@@ -214,14 +214,6 @@ function pickTailnetIPv4(
return pickIPv4Matching(networkInterfaces, isTailnetIPv4);
}
function resolveGatewayTokenFromEnv(env: NodeJS.ProcessEnv): string | undefined {
return normalizeOptionalString(env.OPENCLAW_GATEWAY_TOKEN);
}
function resolveGatewayPasswordFromEnv(env: NodeJS.ProcessEnv): string | undefined {
return normalizeOptionalString(env.OPENCLAW_GATEWAY_PASSWORD);
}
function resolvePairingSetupAuthLabel(
cfg: OpenClawConfig,
env: NodeJS.ProcessEnv,
@@ -236,8 +228,8 @@ function resolvePairingSetupAuthLabel(
value: cfg.gateway?.auth?.password,
defaults,
}).ref;
const envToken = resolveGatewayTokenFromEnv(env);
const envPassword = resolveGatewayPasswordFromEnv(env);
const envToken = normalizeOptionalString(env.OPENCLAW_GATEWAY_TOKEN);
const envPassword = normalizeOptionalString(env.OPENCLAW_GATEWAY_PASSWORD);
const token =
envToken || (tokenRef ? undefined : normalizeSecretInputString(cfg.gateway?.auth?.token));
const password =
@@ -343,8 +335,8 @@ export async function resolvePairingSetupFromConfig(
cfg,
env,
mode: cfg.gateway?.auth?.mode,
hasTokenCandidate: Boolean(resolveGatewayTokenFromEnv(env)),
hasPasswordCandidate: Boolean(resolveGatewayPasswordFromEnv(env)),
hasTokenCandidate: Boolean(normalizeOptionalString(env.OPENCLAW_GATEWAY_TOKEN)),
hasPasswordCandidate: Boolean(normalizeOptionalString(env.OPENCLAW_GATEWAY_PASSWORD)),
});
const authLabel = resolvePairingSetupAuthLabel(cfgForAuth, env);
if (authLabel.error) {