openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
12 lines (11 loc) • 506 B
JavaScript
//#region src/utils/mask-api-key.ts
/** Masks credential-like values for diagnostics while preserving enough prefix/suffix to identify them. */
const maskApiKey = (value) => {
const trimmed = value.trim();
if (!trimmed) return "missing";
if (trimmed.length <= 6) return `${trimmed.slice(0, 1)}...${trimmed.slice(-1)}`;
if (trimmed.length <= 16) return `${trimmed.slice(0, 2)}...${trimmed.slice(-2)}`;
return `${trimmed.slice(0, 8)}...${trimmed.slice(-8)}`;
};
//#endregion
export { maskApiKey as t };