refactor(auth): share api key masking utility

This commit is contained in:
Peter Steinberger
2026-02-18 17:13:35 +00:00
parent 3138dbaf75
commit 288015a9fc
4 changed files with 30 additions and 22 deletions

View File

@@ -12,20 +12,10 @@ import {
import { findNormalizedProviderValue, normalizeProviderId } from "../../agents/model-selection.js";
import type { OpenClawConfig } from "../../config/config.js";
import { shortenHomePath } from "../../utils.js";
import { maskApiKey } from "../../utils/mask-api-key.js";
export type ModelAuthDetailMode = "compact" | "verbose";
const maskApiKey = (value: string): string => {
const trimmed = value.trim();
if (!trimmed) {
return "missing";
}
if (trimmed.length <= 16) {
return trimmed;
}
return `${trimmed.slice(0, 8)}...${trimmed.slice(-8)}`;
};
export const resolveAuthLabel = async (
provider: string,
cfg: OpenClawConfig,