mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 06:47:26 +00:00
feat(secrets): finalize external secrets runtime and migration hardening
This commit is contained in:
committed by
Peter Steinberger
parent
c5b89fbaea
commit
0e69660c41
@@ -7,9 +7,11 @@ describe("maskApiKey", () => {
|
||||
expect(maskApiKey(" ")).toBe("missing");
|
||||
});
|
||||
|
||||
it("returns trimmed value when length is 16 chars or less", () => {
|
||||
expect(maskApiKey(" abcdefghijklmnop ")).toBe("abcdefghijklmnop");
|
||||
expect(maskApiKey(" short ")).toBe("short");
|
||||
it("masks short and medium values without returning raw secrets", () => {
|
||||
expect(maskApiKey(" abcdefghijklmnop ")).toBe("ab...op");
|
||||
expect(maskApiKey(" short ")).toBe("s...t");
|
||||
expect(maskApiKey(" a ")).toBe("a...a");
|
||||
expect(maskApiKey(" ab ")).toBe("a...b");
|
||||
});
|
||||
|
||||
it("masks long values with first and last 8 chars", () => {
|
||||
|
||||
@@ -3,8 +3,11 @@ export const maskApiKey = (value: string): string => {
|
||||
if (!trimmed) {
|
||||
return "missing";
|
||||
}
|
||||
if (trimmed.length <= 6) {
|
||||
return `${trimmed.slice(0, 1)}...${trimmed.slice(-1)}`;
|
||||
}
|
||||
if (trimmed.length <= 16) {
|
||||
return trimmed;
|
||||
return `${trimmed.slice(0, 2)}...${trimmed.slice(-2)}`;
|
||||
}
|
||||
return `${trimmed.slice(0, 8)}...${trimmed.slice(-8)}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user